\(\int (e x)^{-1+n} (a+b \csc (c+d x^n))^2 \, dx\) [76]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [C] (warning: unable to verify)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [F]
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 22, antiderivative size = 80 \[ \int (e x)^{-1+n} \left (a+b \csc \left (c+d x^n\right )\right )^2 \, dx=\frac {a^2 (e x)^n}{e n}-\frac {2 a b x^{-n} (e x)^n \text {arctanh}\left (\cos \left (c+d x^n\right )\right )}{d e n}-\frac {b^2 x^{-n} (e x)^n \cot \left (c+d x^n\right )}{d e n} \]

[Out]

a^2*(e*x)^n/e/n-2*a*b*(e*x)^n*arctanh(cos(c+d*x^n))/d/e/n/(x^n)-b^2*(e*x)^n*cot(c+d*x^n)/d/e/n/(x^n)

Rubi [A] (verified)

Time = 0.11 (sec) , antiderivative size = 80, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.273, Rules used = {4294, 4290, 3858, 3855, 3852, 8} \[ \int (e x)^{-1+n} \left (a+b \csc \left (c+d x^n\right )\right )^2 \, dx=\frac {a^2 (e x)^n}{e n}-\frac {2 a b x^{-n} (e x)^n \text {arctanh}\left (\cos \left (c+d x^n\right )\right )}{d e n}-\frac {b^2 x^{-n} (e x)^n \cot \left (c+d x^n\right )}{d e n} \]

[In]

Int[(e*x)^(-1 + n)*(a + b*Csc[c + d*x^n])^2,x]

[Out]

(a^2*(e*x)^n)/(e*n) - (2*a*b*(e*x)^n*ArcTanh[Cos[c + d*x^n]])/(d*e*n*x^n) - (b^2*(e*x)^n*Cot[c + d*x^n])/(d*e*
n*x^n)

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3852

Int[csc[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> Dist[-d^(-1), Subst[Int[ExpandIntegrand[(1 + x^2)^(n/2 - 1), x]
, x], x, Cot[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[n/2, 0]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3858

Int[(csc[(c_.) + (d_.)*(x_)]*(b_.) + (a_))^2, x_Symbol] :> Simp[a^2*x, x] + (Dist[2*a*b, Int[Csc[c + d*x], x],
 x] + Dist[b^2, Int[Csc[c + d*x]^2, x], x]) /; FreeQ[{a, b, c, d}, x]

Rule 4290

Int[((a_.) + Csc[(c_.) + (d_.)*(x_)^(n_)]*(b_.))^(p_.)*(x_)^(m_.), x_Symbol] :> Dist[1/n, Subst[Int[x^(Simplif
y[(m + 1)/n] - 1)*(a + b*Csc[c + d*x])^p, x], x, x^n], x] /; FreeQ[{a, b, c, d, m, n, p}, x] && IGtQ[Simplify[
(m + 1)/n], 0] && IntegerQ[p]

Rule 4294

Int[((a_.) + Csc[(c_.) + (d_.)*(x_)^(n_)]*(b_.))^(p_.)*((e_)*(x_))^(m_.), x_Symbol] :> Dist[e^IntPart[m]*((e*x
)^FracPart[m]/x^FracPart[m]), Int[x^m*(a + b*Csc[c + d*x^n])^p, x], x] /; FreeQ[{a, b, c, d, e, m, n, p}, x]

Rubi steps \begin{align*} \text {integral}& = \frac {\left (x^{-n} (e x)^n\right ) \int x^{-1+n} \left (a+b \csc \left (c+d x^n\right )\right )^2 \, dx}{e} \\ & = \frac {\left (x^{-n} (e x)^n\right ) \text {Subst}\left (\int (a+b \csc (c+d x))^2 \, dx,x,x^n\right )}{e n} \\ & = \frac {a^2 (e x)^n}{e n}+\frac {\left (2 a b x^{-n} (e x)^n\right ) \text {Subst}\left (\int \csc (c+d x) \, dx,x,x^n\right )}{e n}+\frac {\left (b^2 x^{-n} (e x)^n\right ) \text {Subst}\left (\int \csc ^2(c+d x) \, dx,x,x^n\right )}{e n} \\ & = \frac {a^2 (e x)^n}{e n}-\frac {2 a b x^{-n} (e x)^n \text {arctanh}\left (\cos \left (c+d x^n\right )\right )}{d e n}-\frac {\left (b^2 x^{-n} (e x)^n\right ) \text {Subst}\left (\int 1 \, dx,x,\cot \left (c+d x^n\right )\right )}{d e n} \\ & = \frac {a^2 (e x)^n}{e n}-\frac {2 a b x^{-n} (e x)^n \text {arctanh}\left (\cos \left (c+d x^n\right )\right )}{d e n}-\frac {b^2 x^{-n} (e x)^n \cot \left (c+d x^n\right )}{d e n} \\ \end{align*}

Mathematica [A] (verified)

Time = 2.10 (sec) , antiderivative size = 102, normalized size of antiderivative = 1.28 \[ \int (e x)^{-1+n} \left (a+b \csc \left (c+d x^n\right )\right )^2 \, dx=\frac {x^{-n} (e x)^n \left (-b^2 \cot \left (\frac {1}{2} \left (c+d x^n\right )\right )+2 a \left (a c+a d x^n-2 b \log \left (\cos \left (\frac {1}{2} \left (c+d x^n\right )\right )\right )+2 b \log \left (\sin \left (\frac {1}{2} \left (c+d x^n\right )\right )\right )\right )+b^2 \tan \left (\frac {1}{2} \left (c+d x^n\right )\right )\right )}{2 d e n} \]

[In]

Integrate[(e*x)^(-1 + n)*(a + b*Csc[c + d*x^n])^2,x]

[Out]

((e*x)^n*(-(b^2*Cot[(c + d*x^n)/2]) + 2*a*(a*c + a*d*x^n - 2*b*Log[Cos[(c + d*x^n)/2]] + 2*b*Log[Sin[(c + d*x^
n)/2]]) + b^2*Tan[(c + d*x^n)/2]))/(2*d*e*n*x^n)

Maple [C] (warning: unable to verify)

Result contains higher order function than in optimal. Order 9 vs. order 3.

Time = 1.42 (sec) , antiderivative size = 275, normalized size of antiderivative = 3.44

method result size
risch \(\frac {a^{2} x \,{\mathrm e}^{\frac {\left (-1+n \right ) \left (-i \operatorname {csgn}\left (i e \right ) \operatorname {csgn}\left (i x \right ) \operatorname {csgn}\left (i e x \right ) \pi +i \operatorname {csgn}\left (i e \right ) \operatorname {csgn}\left (i e x \right )^{2} \pi +i \operatorname {csgn}\left (i x \right ) \operatorname {csgn}\left (i e x \right )^{2} \pi -i \operatorname {csgn}\left (i e x \right )^{3} \pi +2 \ln \left (e \right )+2 \ln \left (x \right )\right )}{2}}}{n}-\frac {2 i x \,b^{2} {\mathrm e}^{\frac {\left (-1+n \right ) \left (-i \operatorname {csgn}\left (i e \right ) \operatorname {csgn}\left (i x \right ) \operatorname {csgn}\left (i e x \right ) \pi +i \operatorname {csgn}\left (i e \right ) \operatorname {csgn}\left (i e x \right )^{2} \pi +i \operatorname {csgn}\left (i x \right ) \operatorname {csgn}\left (i e x \right )^{2} \pi -i \operatorname {csgn}\left (i e x \right )^{3} \pi +2 \ln \left (e \right )+2 \ln \left (x \right )\right )}{2}} x^{-n}}{d n \left ({\mathrm e}^{2 i \left (c +d \,x^{n}\right )}-1\right )}-\frac {4 \,\operatorname {arctanh}\left ({\mathrm e}^{i \left (c +d \,x^{n}\right )}\right ) e^{n} a b \,{\mathrm e}^{\frac {i \pi \,\operatorname {csgn}\left (i e x \right ) \left (-1+n \right ) \left (\operatorname {csgn}\left (i e x \right )-\operatorname {csgn}\left (i x \right )\right ) \left (-\operatorname {csgn}\left (i e x \right )+\operatorname {csgn}\left (i e \right )\right )}{2}}}{d e n}\) \(275\)

[In]

int((e*x)^(-1+n)*(a+b*csc(c+d*x^n))^2,x,method=_RETURNVERBOSE)

[Out]

a^2/n*x*exp(1/2*(-1+n)*(-I*csgn(I*e)*csgn(I*x)*csgn(I*e*x)*Pi+I*csgn(I*e)*csgn(I*e*x)^2*Pi+I*csgn(I*x)*csgn(I*
e*x)^2*Pi-I*csgn(I*e*x)^3*Pi+2*ln(e)+2*ln(x)))-2*I*x*b^2*exp(1/2*(-1+n)*(-I*csgn(I*e)*csgn(I*x)*csgn(I*e*x)*Pi
+I*csgn(I*e)*csgn(I*e*x)^2*Pi+I*csgn(I*x)*csgn(I*e*x)^2*Pi-I*csgn(I*e*x)^3*Pi+2*ln(e)+2*ln(x)))/d/n/(x^n)/(exp
(2*I*(c+d*x^n))-1)-4*arctanh(exp(I*(c+d*x^n)))/d/e*e^n/n*a*b*exp(1/2*I*Pi*csgn(I*e*x)*(-1+n)*(csgn(I*e*x)-csgn
(I*x))*(-csgn(I*e*x)+csgn(I*e)))

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 116, normalized size of antiderivative = 1.45 \[ \int (e x)^{-1+n} \left (a+b \csc \left (c+d x^n\right )\right )^2 \, dx=\frac {a^{2} d e^{n - 1} x^{n} \sin \left (d x^{n} + c\right ) - a b e^{n - 1} \log \left (\frac {1}{2} \, \cos \left (d x^{n} + c\right ) + \frac {1}{2}\right ) \sin \left (d x^{n} + c\right ) + a b e^{n - 1} \log \left (-\frac {1}{2} \, \cos \left (d x^{n} + c\right ) + \frac {1}{2}\right ) \sin \left (d x^{n} + c\right ) - b^{2} e^{n - 1} \cos \left (d x^{n} + c\right )}{d n \sin \left (d x^{n} + c\right )} \]

[In]

integrate((e*x)^(-1+n)*(a+b*csc(c+d*x^n))^2,x, algorithm="fricas")

[Out]

(a^2*d*e^(n - 1)*x^n*sin(d*x^n + c) - a*b*e^(n - 1)*log(1/2*cos(d*x^n + c) + 1/2)*sin(d*x^n + c) + a*b*e^(n -
1)*log(-1/2*cos(d*x^n + c) + 1/2)*sin(d*x^n + c) - b^2*e^(n - 1)*cos(d*x^n + c))/(d*n*sin(d*x^n + c))

Sympy [F]

\[ \int (e x)^{-1+n} \left (a+b \csc \left (c+d x^n\right )\right )^2 \, dx=\int \left (e x\right )^{n - 1} \left (a + b \csc {\left (c + d x^{n} \right )}\right )^{2}\, dx \]

[In]

integrate((e*x)**(-1+n)*(a+b*csc(c+d*x**n))**2,x)

[Out]

Integral((e*x)**(n - 1)*(a + b*csc(c + d*x**n))**2, x)

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 207 vs. \(2 (80) = 160\).

Time = 0.26 (sec) , antiderivative size = 207, normalized size of antiderivative = 2.59 \[ \int (e x)^{-1+n} \left (a+b \csc \left (c+d x^n\right )\right )^2 \, dx=-\frac {2 \, b^{2} e^{n} \sin \left (2 \, d x^{n} + 2 \, c\right )}{d e n \cos \left (2 \, d x^{n} + 2 \, c\right )^{2} + d e n \sin \left (2 \, d x^{n} + 2 \, c\right )^{2} - 2 \, d e n \cos \left (2 \, d x^{n} + 2 \, c\right ) + d e n} + \frac {\left (e x\right )^{n} a^{2}}{e n} - \frac {{\left (e^{n} \log \left (\cos \left (d x^{n}\right )^{2} + 2 \, \cos \left (d x^{n}\right ) \cos \left (c\right ) + \cos \left (c\right )^{2} + \sin \left (d x^{n}\right )^{2} - 2 \, \sin \left (d x^{n}\right ) \sin \left (c\right ) + \sin \left (c\right )^{2}\right ) - e^{n} \log \left (\cos \left (d x^{n}\right )^{2} - 2 \, \cos \left (d x^{n}\right ) \cos \left (c\right ) + \cos \left (c\right )^{2} + \sin \left (d x^{n}\right )^{2} + 2 \, \sin \left (d x^{n}\right ) \sin \left (c\right ) + \sin \left (c\right )^{2}\right )\right )} a b}{d e n} \]

[In]

integrate((e*x)^(-1+n)*(a+b*csc(c+d*x^n))^2,x, algorithm="maxima")

[Out]

-2*b^2*e^n*sin(2*d*x^n + 2*c)/(d*e*n*cos(2*d*x^n + 2*c)^2 + d*e*n*sin(2*d*x^n + 2*c)^2 - 2*d*e*n*cos(2*d*x^n +
 2*c) + d*e*n) + (e*x)^n*a^2/(e*n) - (e^n*log(cos(d*x^n)^2 + 2*cos(d*x^n)*cos(c) + cos(c)^2 + sin(d*x^n)^2 - 2
*sin(d*x^n)*sin(c) + sin(c)^2) - e^n*log(cos(d*x^n)^2 - 2*cos(d*x^n)*cos(c) + cos(c)^2 + sin(d*x^n)^2 + 2*sin(
d*x^n)*sin(c) + sin(c)^2))*a*b/(d*e*n)

Giac [F]

\[ \int (e x)^{-1+n} \left (a+b \csc \left (c+d x^n\right )\right )^2 \, dx=\int { {\left (b \csc \left (d x^{n} + c\right ) + a\right )}^{2} \left (e x\right )^{n - 1} \,d x } \]

[In]

integrate((e*x)^(-1+n)*(a+b*csc(c+d*x^n))^2,x, algorithm="giac")

[Out]

integrate((b*csc(d*x^n + c) + a)^2*(e*x)^(n - 1), x)

Mupad [B] (verification not implemented)

Time = 20.61 (sec) , antiderivative size = 182, normalized size of antiderivative = 2.28 \[ \int (e x)^{-1+n} \left (a+b \csc \left (c+d x^n\right )\right )^2 \, dx=\frac {a^2\,x\,{\left (e\,x\right )}^{n-1}}{n}-\frac {b^2\,x\,{\left (e\,x\right )}^{n-1}\,2{}\mathrm {i}}{d\,n\,x^n\,\left ({\mathrm {e}}^{c\,2{}\mathrm {i}+d\,x^n\,2{}\mathrm {i}}-1\right )}-\frac {2\,a\,b\,x\,\ln \left (-a\,b\,{\left (e\,x\right )}^{n-1}\,4{}\mathrm {i}-a\,b\,{\mathrm {e}}^{c\,1{}\mathrm {i}}\,{\mathrm {e}}^{d\,x^n\,1{}\mathrm {i}}\,{\left (e\,x\right )}^{n-1}\,4{}\mathrm {i}\right )\,{\left (e\,x\right )}^{n-1}}{d\,n\,x^n}+\frac {2\,a\,b\,x\,\ln \left (a\,b\,{\left (e\,x\right )}^{n-1}\,4{}\mathrm {i}-a\,b\,{\mathrm {e}}^{c\,1{}\mathrm {i}}\,{\mathrm {e}}^{d\,x^n\,1{}\mathrm {i}}\,{\left (e\,x\right )}^{n-1}\,4{}\mathrm {i}\right )\,{\left (e\,x\right )}^{n-1}}{d\,n\,x^n} \]

[In]

int((a + b/sin(c + d*x^n))^2*(e*x)^(n - 1),x)

[Out]

(a^2*x*(e*x)^(n - 1))/n - (b^2*x*(e*x)^(n - 1)*2i)/(d*n*x^n*(exp(c*2i + d*x^n*2i) - 1)) - (2*a*b*x*log(- a*b*(
e*x)^(n - 1)*4i - a*b*exp(c*1i)*exp(d*x^n*1i)*(e*x)^(n - 1)*4i)*(e*x)^(n - 1))/(d*n*x^n) + (2*a*b*x*log(a*b*(e
*x)^(n - 1)*4i - a*b*exp(c*1i)*exp(d*x^n*1i)*(e*x)^(n - 1)*4i)*(e*x)^(n - 1))/(d*n*x^n)